/*banner*/
!function (a) {
    a.fn.extend({
        YuxiSlider: function (b) {
            var c = {
                width: 750,
                height: 360,
                control: null,
                auto: 1,
                during: 3e3,
                speed: 800,
                mousewheel: !1,
                direkey: !1
            }, d = a.extend(c, b);
            return a(this).each(function () {
                var b = a(this), c = a("ul", b), e = a("li", b), f = e.length, g = 0, h = null,
                    i = '<div class="desc"><p class="title"></p><span class="num"><em class="curr-num"></em><em class="line">／</em><em class="total-num"></em></span></div>';
                b.append(i);
                var j = a("p.title a", b), k = a("em.curr-num", b), l = a("em.total-num", b), m = 0, n = {}, o = {},
                    p = {
                        mobileDevice: navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i), init: function () {
                            if (p.style(), p.mobileDevice) {
                                var deviceWidth = document.documentElement.clientWidth;
                                var e = a(window).width(), g = d.width / d.height;
                                d.width = e, d.height = e / g,
                                    // b.css({fontSize: deviceWidth /7.5 + 'px'})
                                    document.documentElement.style.fontSize = deviceWidth / 7.5 + 'px';
                            }
                            b.add("img", b).width(d.width).height(d.height), c.width(f * d.width), p.description(), p.bindControl(), f > 2 && c.prepend(a("li", c).last()).css({left: -d.width}), d.auto && p.auto()
                        }, auto: function () {
                            h = d.auto ? setInterval(function () {
                                p.moving(!0)
                            }, d.during) : null
                        }, stop: function () {
                            h && clearInterval(h)
                        }, description: function () {
                            k.text(g + 1), l.text(f), j.text(e.eq(g).find("").attr("aaa")).attr("href", e.eq(g).find("a").attr("href")).width(d.width - a("span.num", b).width() - 20)
                        }, bindControl: function () {
                            if (p.mobileDevice) {
                                if (d.control && d.control.remove(), 2 >= f) return;
                                c.get(0).addEventListener("touchstart", p.touchstart, !1), c.get(0).addEventListener("touchmove", p.touchmove, !1), c.get(0).addEventListener("touchend", p.touchend, !1)
                            } else {
                                b.hover(function () {
                                    d.auto && p.stop(), a(document).on("keydown", function (a) {
                                        a.preventDefault(), (39 === a.keyCode || 40 === a.keyCode) && p.moving(!0), (37 === a.keyCode || 38 === a.keyCode) && p.moving(!1)
                                    })
                                }, function () {
                                    a(document).unbind(), d.auto && p.auto()
                                });
                                var e = void 0 !== document.mozHidden ? "DOMMouseScroll" : "mousewheel";
                                d.mousewheel && b.on(e, function (a) {
                                    a.preventDefault(), a.stopPropagation();
                                    var c = a.originalEvent.wheelDelta ? a.originalEvent.wheelDelta : -a.originalEvent.detail,
                                        d = b.data("timeoutId");
                                    d && clearInterval(d), b.data("timeoutId", setTimeout(function () {
                                        p.moving(0 > c ? !0 : !1), b.removeData("timeoutId")
                                    }, 100))
                                }), d.control && d.control.on("click", function () {
                                    p.moving(a(this).index() ? !0 : !1)
                                }).hover(function () {
                                    d.auto && p.stop()
                                }, function () {
                                    d.auto && p.auto()
                                })
                            }
                        }, moving: function (b) {
                            if (1 != f) {
                                var e = 0, h = !0;
                                "boolean" == typeof b ? h = b : (h = b > 0 ? !1 : !0, e = b), g = h ? g >= f - 1 ? 0 : g + 1 : 0 >= g ? f - 1 : g - 1, p.description(), f > 2 ? (h ? c.append(a("li", c).first()).css({left: 0 + e}) : c.prepend(a("li", c).last()).css({left: -2 * d.width + e}), c.stop().animate({left: [-d.width, "easeOutExpo"]}, d.speed)) : h ? c.stop().animate({left: -d.width}, .6 * d.speed, function () {
                                    a(this).append(a("li", this).first()).css({left: 0})
                                }) : c.prepend(a("li", c).last()).css({left: -d.width + e}).stop().animate({left: 0}, .6 * d.speed)
                            }
                        }, touchPos: function (a) {
                            for (var c, d, e, b = a.changedTouches, f = {}, g = 0; g < b.length; g++) c = b[g], d = c.clientX, e = c.clientY;
                            return f.x = d, f.y = e, f
                        }, touchstart: function (a) {
                            p.stop(), m = (new Date).getTime(), n = p.touchPos(a), o.left = c.offset().left
                        }, touchmove: function (a) {
                            a.preventDefault();
                            var b = p.touchPos(a).x - n.x;
                            c.stop().css({left: o.left + b})
                        }, touchend: function (a) {
                            var b = p.touchPos(a).x - n.x, e = (new Date).getTime() - m;
                            0 !== Math.abs(b) && (350 >= e ? p.moving(b) : Math.abs(b) <= d.width / 2 ? c.stop().animate({left: [o.left, "easeOutExpo"]}, d.speed / 2) : p.moving(b), d.auto && p.auto())
                        }, style: function () {
                            b.css({position: "relative", overflow: "hidden"}).fadeIn(450), e.css({
                                display: "inline",
                                "float": "left"
                            }), c.add(a(".bg", b)).add(a(".desc", b)).add(a(".num", b)).css({position: "absolute"}), a(".bg", b).css({
                                background: "#000",
                                filter: "alpha(opacity=50)",
                                opacity: .5
                            }).add(a(".desc", b)).css({
                                width: "100%",
                                height: ".3em",
                                bottom: ".1em",
                                left: 0
                            }), a(".desc").css({zIndex: 2}), a("p.title", b).css({
                                "float": "left",
                                height: ".1em",
                                padding: ".1em .05em",
                            }), a("p.title a", b).css({
                                display: "block",
                                color: "#333",
                                textOverflow: "ellipsis",
                                whiteSpace: "nowrap",
                                overflow: "hidden"
                            }), a("span.num", b).css({
                                right: "0.2rem",
                                color: "#fff",
                                fontStyle: "italic",
                                bottom:"0.3rem"
                            }), a("em", b).css({
                                display: "inline-block",
                                position: "relative"
                            }), a("em.curr-num", b).css({
                                fontSize: ".24rem",
                                height: ".2em",
                                lineHeight: ".2em",
                                top: ".06em",
                                color: "#fcfcfc"
                            }), a("em.total-num", b).css({
                                fontSize: ".24rem",
                                height: ".2em",
                                lineHeight: ".2em",
                                top: ".06em",
                                color: "#fcfcfc"
                            }), a("em.line", b).css({
                                fontSize: ".24rem",
                                height: ".2em",
                                lineHeight: ".2em",
                                top: ".06em",
                                color: "#fcfcfc"
                            })
                        }
                    };
                p.init()
            })
        }
    })
}(jQuery), $.extend($.easing, {
    easeOutExpo: function (a, b, c, d, e) {
        return b == e ? c + d : d * (-Math.pow(2, -10 * b / e) + 1) + c
    }
});

/*rem*/
var deviceWidth = document.documentElement.clientWidth;
if(deviceWidth > 750) deviceWidth = 750;
document.documentElement.style.fontSize = deviceWidth / 7.5 + 'px';

/*滚动*/
/**
 * @classDescription 模拟Marquee，无间断滚动内容
 *
 * @DOM
 *  	<div id="marquee">
 *  		<ul>
 *   			<li></li>
 *   			<li></li>
 *  		</ul>
 *  	</div>
 * @CSS
 *  	#marquee {overflow:hidden;width:200px;height:50px;}
 * @Usage
 *  	$("#marquee").kxbdMarquee(options);
 * @options
 *		isEqual:true,		//所有滚动的元素长宽是否相等,true,false
 *  	loop:0,				//循环滚动次数，0时无限
 *		direction:"left",	//滚动方向，"left","right","up","down"
 *		scrollAmount:1,		//步长
 *		scrollDelay:20		//时长
 */
(function($){
    $.fn.kxbdMarquee=function(options){
        var opts=$.extend({},$.fn.kxbdMarquee.defaults, options);

        return this.each(function(){
            var $marquee=$(this);				//滚动元素容器
            var _scrollObj=$marquee.get(0);		//滚动元素容器DOM
            var scrollW=$marquee.width();		//滚动元素容器的宽度
            var scrollH=$marquee.height();		//滚动元素容器的高度
            var $element=$marquee.children();	//滚动元素
            var $kids=$element.children();		//滚动子元素
            var scrollSize=0;					//滚动元素尺寸

            //滚动类型，1左右，0上下
            var _type=(opts.direction=="left"||opts.direction=="right") ? 1:0;

            //防止滚动子元素比滚动元素宽而取不到实际滚动子元素宽度
            $element.css(_type?"width":"height",10000);

            //获取滚动元素的尺寸
            if(opts.isEqual){
                scrollSize=$kids[_type?"outerWidth":"outerHeight"]()*$kids.length;
            }else{
                $kids.each(function(){
                    scrollSize+=$(this)[_type?"outerWidth":"outerHeight"]();
                });
            };

            //滚动元素总尺寸小于容器尺寸，不滚动
            if(scrollSize<(_type?scrollW:scrollH)){return;};

            //克隆滚动子元素将其插入到滚动元素后，并设定滚动元素宽度
            $element.append($kids.clone()).css(_type?"width":"height",scrollSize*2);

            var numMoved=0;
            function scrollFunc(){
                var _dir=(opts.direction=="left"||opts.direction=="right") ? "scrollLeft":"scrollTop";
                if (opts.loop>0) {
                    numMoved+=opts.scrollAmount;
                    if(numMoved>scrollSize*opts.loop){
                        _scrollObj[_dir]=0;
                        return clearInterval(moveId);
                    };
                };

                if(opts.direction=="left"||opts.direction=="up"){
                    var newPos=_scrollObj[_dir]+opts.scrollAmount;
                    if(newPos>=scrollSize){
                        newPos-=scrollSize;
                    }
                    _scrollObj[_dir]=newPos;
                }else{
                    var newPos=_scrollObj[_dir]-opts.scrollAmount;
                    if(newPos<=0){
                        newPos += scrollSize;
                    };
                    _scrollObj[_dir]=newPos;
                };
            };

            //滚动开始
            var moveId=setInterval(scrollFunc, opts.scrollDelay);

            //鼠标划过停止滚动
            $marquee.hover(function(){
                clearInterval(moveId);
            },function(){
                clearInterval(moveId);
                moveId=setInterval(scrollFunc, opts.scrollDelay);
            });
        });
    };

    $.fn.kxbdMarquee.defaults={
        isEqual:true,		//所有滚动的元素长宽是否相等,true,false
        loop: 0,			//循环滚动次数，0时无限
        direction: "left",	//滚动方向，"left","right","up","down"
        scrollAmount:1,		//步长
        scrollDelay:20		//时长

    };

    $.fn.kxbdMarquee.setDefaults=function(settings) {
        $.extend( $.fn.kxbdMarquee.defaults, settings );
    };
})(jQuery);


